package ca.unbc.cpsc672.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import ca.unbc.cpsc672.rcmd.DBUtils;

public class ViewDerbyDb {
	public static void main(String[] args) throws SQLException {
		new org.apache.derby.jdbc.EmbeddedDriver();
		Connection conn = DriverManager.getConnection(DBUtils.DERBY_URL);
		String sql = "update yelp_data set stars = stars + 0.1 where id = '7_y_M5wRaSvNXt-q4xvlEQ'";
//		try (ResultSet rs = conn.createStatement().executeQuery(sql)) {
//			while (rs.next()) {
//				System.out.println(rs.getString(1));
//				System.out.println(rs.getString(2));
//			}
//		}
		System.out.println(conn.createStatement().executeUpdate(sql));
		
		String sql2 = "select stars from yelp_data where id = '7_y_M5wRaSvNXt-q4xvlEQ'";
		try (ResultSet rs = conn.createStatement().executeQuery(sql2)) {
			while (rs.next()) {
				System.out.println(rs.getString(1));
			}
		}
		conn.close();
	}
}
